package com.github.ghsea.scheduler.util;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author guhai
 * @since 2020/2/22 18:06
 */
public class JsonUtils {

    public static String asJson(Object source) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(source);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

}
